﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="YUITableList.aspx.cs" Inherits="ZX.WebApp.EditWidows.YUITableList" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <!--CSS file (default YUI Sam Skin) -->
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/reset-fonts-grids/reset-fonts-grids.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/container/assets/skins/sam/container.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/menu/assets/skins/sam/menu.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/button/assets/skins/sam/button.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/resize/assets/skins/sam/resize.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/layout/assets/skins/sam/layout.css" />
    <link type="text/css" rel="stylesheet" href="../Scripts/yui_2.9.0/build/datatable/assets/skins/sam/datatable.css" />
    <link rel="stylesheet" type="text/css" href="../Scripts/yui_2.9.0/build/fonts/fonts-min.css" />
    <!--begin custom header content for this example-->
    <style type="text/css">
    .yui-skin-sam table {
	    width: 100%;
    }
    #tree {background: #fff; padding:1em;}

    #button-example-form fieldset, 
    #button-example-form fieldset div {

        border: 2px groove #ccc;
        margin: .5em;
        padding: .5em;
    }
    .yui-button#pushbutton2 button,
    .yui-button#pushbutton5 button, 
    .yui-button .Add button {
        background: url(../button/assets/add.gif) center center no-repeat;
        text-indent: -4em;
        overflow: hidden;
        padding: 0 .75em;
        width: 2em;
        *margin-left: 4em;   /* IE only */
        *padding: 0 1.75em;  /* IE only */
    }   
    .yui-button#pushbutton3 button,
    .yui-button#pushbutton6 button, 
    .yui-button#pushbutton9 button {
        padding-left: 2em;
        background: url(../button/assets/add.gif) 10% 50% no-repeat;
    }
    <% =DataTableCss %>
    </style>
    <!--end custom header content for this example-->
    <!-- Dependencies -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/element/element-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datasource/datasource-min.js"></script>
    <!-- OPTIONAL: JSON Utility (for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/json/json-min.js"></script>
    <!-- OPTIONAL: Connection Manager (enables XHR for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/connection/connection-min.js"></script>
    <!-- OPTIONAL: Get Utility (enables dynamic script nodes for DataSource) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/get/get-min.js"></script>
    <!-- OPTIONAL: Drag Drop (enables resizeable or reorderable columns) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/dragdrop/dragdrop-min.js"></script>
    <!-- OPTIONAL: Calendar (enables calendar editors) -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/calendar/calendar-min.js"></script>
    <!-- Source files -->
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/datatable/datatable-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/layout/layout-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/button/button-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/container/container-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/treeview/treeview-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/resize/resize-min.js"></script>
    <script type="text/javascript" src="../Scripts/yui_2.9.0/build/paginator/paginator-min.js"></script>
</head>
<body class="yui-skin-sam">
    <form id="form1" runat="server">
    <!-- 工具栏 -->
    
        <div id="left"></div>
        <div id="toolbar" style="margin: 2px;">
            <% =BtnItems %> <button type="button" id="btnFull" name="btnFull">
                全屏</button><button type="button" id="btnReload" name="btnReload">
                刷新</button> <button type="button" id="btnClose" name="btnClose">
                关闭当前页</button> 
        </div>
        <div id="data">
            <div id="json">
            </div>
        </div>
        <div id="bottom">

        </div>
    <div id="dialog1" class="yui-pe-content">
        <div class="hd">
            数据编辑</div>
        <div class="bd">
            <iframe id="EditUIWindow" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog2" class="yui-pe-content">
        <div class="hd">
            部门选择</div>
        <div class="bd">
            <iframe id="EditUIWindow1" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog3" class="yui-pe-content">
        <div class="hd">
            提示</div>
        <div class="bd">
            你正在删除当前选择的数据，继续请按确定？
        </div>
    </div>
    <div id="dialog4" class="yui-pe-content">
        <div class="hd">
            问卷题目</div>
        <div class="bd">
            <iframe id="EditUIWindow4" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    <div id="dialog5" class="yui-pe-content">
        <div class="hd">
            <% =PageTitle %>
            数据详情</div>
        <div class="bd">
            <iframe id="EditUIWindow3" frameborder="0" src="" style="width: 100%; height: 100%;
                margin: 0px; padding: 0px;"></iframe>
        </div>
    </div>
    </form>
</body>
<!--  用于加载自定义脚本 -->
<!-- 通用方法 -->
<script src="../Scripts/common.js"  type="text/javascript"></script>
<!-- 定义数据格式化方法 -->
<script src="../Scripts/yui.list.dataformat.js" type="text/javascript"></script>
<!--  用于加载自定义脚本 -->
<script src="../Scripts/appjs/model.<% =EntityName %>.js" type="text/javascript" language="javascript"></script> 

<script type="text/javascript" language="javascript">
(function() {
    var Dom = YAHOO.util.Dom,
        Event = YAHOO.util.Event;
 
    Event.onDOMReady(function() {
        var layout = new YAHOO.widget.Layout({
            minWidth: 1000,
            minHeight: 500,
            units: [
                { position: 'left', width: 200, resize: true, body: 'left', gutter: '2px 0px', collapseSize: 50, scroll: true, maxWidth: 300 },
                { position: 'center', minWidth: 400, minHeight: 200 }
            ]
        });
        layout.on('render', function() {
            var el = layout.getUnitByPosition('center').get('wrap');
            var layout2 = new YAHOO.widget.Layout(el, {
                parent: layout,
                minWidth: 400,
                minHeight: 200,
                units: [

                    { position: 'top', body: 'toolbar', height: 35, gutter: '1px', maxHeight: 80 },
                    { position: 'bottom',  height: 35, resize: true, body: 'bottom1', gutter: '1px', maxHeight: 130 },
                    { position: 'center', body: 'data', gutter: '1px', scroll: true }
                ]
            });
             layout2.render();
        });
       layout.render();
       InitLeftData();
    });
})();
var const_entityID = "<% =EntityId %>",    //实体ID名称
        const_entityName = "<% =EntityName %>",//实体名称
        const_EditEntity = "<% =EditEntity %>",//编辑实体名
        const_functionId   ="<% =FunctionID %>" ,//自定义条件
        const_Order ="<% =Order %>",
        const_UserId = "<% = UserId %>",
        const_DataFields = [<% =DataFields %>],
        const_DataColums = [<% =DataColums %>],
        const_CustomCondition=window.decodeURI("<%=ForeignKey%>='"+<% =Guid.Empty %>+"'");
        selectControl=null,
        requireUrl="",
        initialRequestUrl= "pageindex=1&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ decodeURI(const_CustomCondition);//要删除的数据列var const_entityID = "<% =EntityId %>",    //实体ID名称
      


YAHOO.example.init = function () {
    function onButtonClick(p_oEvent) {
        YAHOO.log("You clicked button: " + this.get("id"), "info", "example1");
        switch(this.get("id"))
        { 
            <% =InitBtnEvents %>
            case "btnFull": 
                    fnFull();
                    break;
            case "btnClose":
                    fnAddMasterDetail();
                    //window.parent.$("#tabs").tabs('close','<% =PageTitle %>');
                    break;
            case "btnReload":
                    fnReload();
                    break;
            default:
                    break;
        }                        
    }
    YAHOO.util.Event.onContentReady("toolbar", function () {
        <% =BtnEvents  %>
       var btnFull = new YAHOO.widget.Button("btnFull");
        btnFull.on("click", onButtonClick);
        var btnClose = new YAHOO.widget.Button("btnClose");
        btnClose.on("click", onButtonClick);
        var btnReload = new YAHOO.widget.Button("btnReload");
        btnReload.on("click", onButtonClick);
    });
}();

var mDataTable;
function InitLeftData() {
       YAHOO.example.EHR_JSON = function() {
            var myColumnDefs = [{key:'Caption',label:'标题',sortable:true}];

            var myDataSource = new YAHOO.util.DataSource("../Extend/AjaxData/JSONList.aspx?");
            myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
            myDataSource.connXhrMode = "queueRequests";
            myDataSource.responseSchema = {
                resultsList: "rows",
                fields: ["Key","Caption"]
            };
        
            this.myDataTable1 = new YAHOO.widget.DataTable("left", myColumnDefs,
                    myDataSource, {initialRequest: "entity=V_SetTableList&condition="+encodeURI("TableName='<% =LeftTable %>'")+"&output=json&r="+Math.random()+"",selectionMode:"single"  });
                var mySuccessHandler = function() {
                this.set("sortedBy", null);
                this.onDataReturnAppendRows.apply(this,arguments);
            };
            var myFailureHandler = function() {
                this.showTableMessage(YAHOO.widget.DataTable.MSG_ERROR, YAHOO.widget.DataTable.CLASS_ERROR);
                this.onDataReturnAppendRows.apply(this,arguments);
            };

            var mySuccessHandlers = function(){
                mySuccessHandler();
                var recs = myDataTable1.getRecordSet();
                if(recs._records.length>0)
                {
                    LoadData(recs._records[0]._oData["Key"]);
                }
            };
            var callbackObj = {
                success : mySuccessHandlers,
                failure : myFailureHandler,
                scope : myDataTable1
            }
            //var pId;
            var OnRowSelected=function(){
                var recordID = myDataTable1.getSelectedRows()[0];
                record = myDataTable1.getRecord(recordID);
                ParentID = record.getData("Key");
                //alert(ParentID);
                requireUrl="../Extend/AjaxData/JSONList.aspx?";
                  const_CustomCondition=window.decodeURI("<%=ForeignKey%>='"+ParentID+"'");
                 initialRequestUrl= "pageindex=1&entity=" + const_entityName + "&order="+const_Order+"&r="+Math.random()+"&zip=94089&results=10&output=json&functionid="+const_functionId+"&customCondition="+ decodeURI(const_CustomCondition),
         BindData();
                
            };
            // 调用自定义双击行的方法
            var onRowDoubleClick = function () {
              alert('1');
                if (typeof (CustomDbClick) == "function") {
                    CustomDbClick();
                }
            };
	        // Subscribe to events for row selection 
	        this.myDataTable1.subscribe("rowMouseoverEvent", this.myDataTable1.onEventHighlightRow); 
	        this.myDataTable1.subscribe("rowMouseoutEvent", this.myDataTable1.onEventUnhighlightRow); 
            this.myDataTable1.subscribe("rowClickEvent", this.myDataTable1.onEventSelectRow); 
            this.myDataTable1.subscribe("rowClickEvent", OnRowSelected); 
            this.myDataTable1.subscribe("rowDblclickEvent", onRowDoubleClick);
            // Programmatically select the first row 
            this.myDataTable1.selectRow(this.myDataTable1.getTrEl(0)); 
            //var hideid= function(){ this.myDataTable.hideColumn(parseInt(0)); this.myDataTable.refreshView(); };
            //hideid();
     }();
}

var ParentID;
function LoadData(pId) {
    alert(pId);
   
}

</script>

<!-- YUI  通用功能  -->
<script src="../Scripts/yui.list.common.js" type="text/javascript"></script>  
<!--  用于加载按扭方法 -->
<script src="../Scripts/yui.list.button.event.js" type="text/javascript"></script>
</html>
